#!/usr/bin/env python

import sys
import numpy as np
from scipy import signal
from scipy.fft import fftshift
import matplotlib.pyplot as plt
import soundfile as sf

from matplotlib.ticker import AutoMinorLocator, MultipleLocator

filename = sys.argv[1]

data, samplerate = sf.read(filename)

fig, ax = plt.subplots()

fs = 10e3
Pxx, freqs, bins, im = plt.specgram(data[:,0], NFFT=1024, Fs=fs)
x1, x2, y1, y2 = plt.axis()


plt.ylabel('freq [Hz]')
plt.xlabel('time [sec]')

plt.yticks(np.arange(0, 5000, step=1000), fontsize=8)

plt.gca().yaxis.set_major_locator(MultipleLocator(1000))
plt.gca().yaxis.set_minor_locator(MultipleLocator(100))
plt.gca().yaxis.set_minor_formatter('')
plt.grid(axis='y', color='black', linestyle='--', linewidth=0.25, which='minor', alpha=0.3)
plt.grid(axis='y', color='black', linestyle='--', linewidth=0.5, which='major')

plt.show()
